<table class="layui-table layui-table-add layui-table-detail" lay-skin="nob">
    <tbody>
    <tr>
        <th>原密码</th>
        <td>
            <div class="table-input">
                <input type="password" name="" placeholder="请输入旧密码" id="oldPwd" autocomplete="off" class="layui-input">
            </div>
        </td>
    </tr>
    <tr>
        <th>新密码</th>
        <td>
            <div class="table-input">
                <input type="password" name="" placeholder="请输入新密码" id="newPwd" autocomplete="off" class="layui-input">
            </div>
        </td>
    </tr>
    <tr>
        <th>确认密码</th>
        <td>
            <div class="table-input">
                <input type="password" name="" placeholder="请重复新密码" id="newConfirmPwd" autocomplete="off"
                       class="layui-input">
            </div>
        </td>
    </tr>
    </tbody>
</table>
<div class="layui-table-btn2 ">
    <a class="layui-btn" href="javascript:;" id="btn_submit">确 定</a>
    <a class="layui-btn layui-btn-primary cancel" onclick="window.history.back()">取 消</a>
</div>
<#macro script>
    <script>
        layui.use(['jquery'], function () {
            var $ = layui.jquery;
            $(function () {
                $("#btn_submit").on("click", function () {
                    var data = {
                        oldPwd: $("#oldPwd").val(),
                        newPwd: $("#newPwd").val(),
                        newConfirmPwd: $("#newConfirmPwd").val()
                    };
                    if (data.oldPwd == "" || data.newPwd == "" || data.newConfirmPwd == "") {
                        layer.msg("信息未填写完整");
                        return;
                    }
                    if (data.newPwd != data.newConfirmPwd) {
                        layer.alert('新密码两次输入不一致', function (index) {
                            layer.close(index);
                        });
                        return;
                    }
                    $.ajax({
                        type: "POST",
                        url: "/administrate/updatepwd/exec",
                        data: data,
                        async: false,
                        dataType: "json",
                        success: function (result) {
                            if (result.code == 200) {
                                layer.alert('修改成功,请重新登录', function () {
                                    location.href = location.href;
                                });
                            } else {
                                layer.msg(result.msg);
                            }
                        }
                    });
                });
            });
        });
    </script>
</#macro>